package org.csu.group4.jpetstore.persistence;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.csu.group4.jpetstore.mybatis.entity.Orders;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.util.List;

@Mapper
@Component
public interface OrdersDAO {
    @Select("select * from orders")
    List<Orders> findAll();
    @Select("select * from orders where userid = #{username}")
    List<Orders> findByUserId(String username);
    @Select("select * from orders where orderid = #{orderId}")
    Orders findByOrderId(String orderId);

    @Insert("insert into orders(userid, orderdate, shipaddr1, shipaddr2, shipcity, shipstate, shipzip, shipcountry, billaddr1, billaddr2, billcity, billstate, billzip, billcountry, courier, totalprice) " +
            "values (#{userId}, #{orderDate}, #{shipAddr1}, #{shipAddr2}, #{shipCity}, #{shipState}, #{shipZip}, #{shipCountry}, #{billAddr1}, #{billAddr2}, #{billCity}, #{billState}, #{billZip}, #{billCountry}, #{courier}, #{totalPrice})")
    int save(Orders orders);

}
